import 'package:dio/dio.dart';
import 'package:meePet/utils/LogUtils.dart';

import 'CommonApi.dart';
///
class RequestManager {
  static CommonClient? _client;
  static CommonClient? _userClient;

  RequestManager._internal();

  static CommonClient getClient() {
    _client ??= CommonClient(_commonDio(),baseUrl: "https://api.xingyunxcx.com");
    return _client!;
  }

  static CommonClient getUserClient() {
    _userClient ??= CommonClient(_commonDio(),baseUrl: "https://user-facade-api.tandian.net");
    return _userClient!;
  }

  static Dio _commonDio() {
    final dio = Dio();
    String userAgent =
        "Mozilla/5.0 (Linux; Android 13; SM-N981U Build/TP1A.220624.014; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/111.0.5563.116 Mobile Safari/537.36 giao#AppName/coslove Channel/default AppVersion/4.5.0 IsBanana/0 OS/Android AppTag/main Muid/a7cd1716faa32583f867f46ae3b73412";
    dio.options.headers['User-Agent'] = userAgent;

    ///打印请求日志
    dio.interceptors.add(LogInterceptor(
        logPrint: (o) => LogUtils.d(o.toString(), tag: "okhttp")));
    return dio;
  }
}
